package com.lhb.service.Impl;

import com.lhb.common.constant.common;
import com.lhb.mapper.LoginMapper;
import com.lhb.pojo.entity.User;
import com.lhb.service.LoginJFrameService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.swing.*;

@Service
@Slf4j
public class LoginJFrameServiceImpl implements LoginJFrameService {

    @Autowired
    private LoginMapper loginMapper;

    /**
     * 检查用户密码是否正确
     * @param username
     * @param password
     * @return
     */
    public boolean login(String username, String password) {

        log.info("检查用户名:{},密码:{}", username, password);

        User user = new User();
        user.setUsername(username);
        user.setPassword(password);

        return loginMapper.Login(user)!=null;
    }

    /**
     * 重置密码
     *
     * @param usernameText
     * @return
     */
    @Override
    public void resetPassword(String usernameText) {
        log.info("重置用户{}的密码为:{}", usernameText, common.PASSWORD_RESET);


        loginMapper.resetPassword(usernameText);


    }
}
